package com.unisound.tracelog.server;

import io.micrometer.core.instrument.MeterRegistry;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.actuate.autoconfigure.metrics.MeterRegistryCustomizer;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableScheduling;

@SpringBootApplication
@MapperScan(basePackages = {"com.unisound.tracelog.server.mapper"})
@EnableScheduling
public class TraceLogServerApp {
    public static void main(String[] args) {
        SpringApplication.run(TraceLogServerApp.class, args);
    }

    /**
     * 对接普罗米修斯
     * @param applicationName
     * @return
     */
    @Bean
    MeterRegistryCustomizer<MeterRegistry> meterRegistryCustomizer(@Value("${spring.application.name}")String applicationName) {
        return registry -> registry.config().commonTags("application", applicationName);
    }
}
